package jm.mq.bootconfirm.web;

import jm.mq.bootconfirm.conf.BingConf;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 消费者控制类
 * @date 2022/3/13 9:31
 */
@Slf4j
@RestController
@RequestMapping("/confirm")
public class SendMessageController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/confirm/{message}")
    public void sendMsg(@PathVariable String message){
        CorrelationData correlationData = new CorrelationData("1");
        rabbitTemplate.convertAndSend(BingConf.CONFIRM_EXCHANGE,
                BingConf.CONFIRM_ROTING_KEY + "1",message,correlationData);
        log.info("消息内容：{}",message);
    }
}
